package com.tmeone.erpone.controller;


import com.tmeone.erpone.entity.SUserRole;
import com.tmeone.erpone.service.ISUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.lang.model.element.NestingKind;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author tmeone
 * @since 2021-04-16
 */
@RestController
public class SUserRoleController {

    @Autowired
    private ISUserRoleService userRoleService;

    @RequestMapping("/usER/{id}")
    public String select(@PathVariable String id) {

        List<SUserRole> list = userRoleService.list();
        String str="0";
        for (SUserRole sUserRole : list) {
            if (sUserRole.getUserId().equals(id)) {
                str=sUserRole.getRoleId();
            }

        }
        return str;
    }

    @RequestMapping(value = "/roleUserLcal/{roleIdL}/{roleId}/{userId}",method = RequestMethod.PUT)
    public void selectUerRer(@PathVariable String roleIdL, @PathVariable String roleId,@PathVariable String userId){
       userRoleService.insertUserRole(userId,roleIdL,roleId);
        System.out.println("拿值输出:"+roleIdL+"-------"+roleId+"______"+userId);
    }
}

